package com.gl.saasservice.repository;


import com.gl.saasservice.entity.RolePermission;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface RolePermissionRepository extends JpaRepository<RolePermission, Long>, JpaSpecificationExecutor<RolePermission> {

    @Transactional
    void deleteByPermissionIdIn(List<Long> permissionsIds);

    @Transactional
    void deleteByRoleId(Long id);

    List<RolePermission> findByRoleId(Long roleId);

    List<RolePermission> findByPermissionId(Long permissionsId);

    List<RolePermission> findByPermissionIdIn(List<Long> permissionsIds);

    @Transactional
    void deleteByRoleIdInAndPermissionIdIn(List<Long> roleIds, List<Long> permissionsIds);

}
